# Class to make requests to Google CSE API
=begin
Copyright (C) 2014 Enrique Rando

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

http://www.gnu.org/licenses/gpl-2.0.html
=end

=begin

THIS CLASS IS MEANT FOR EDUCATIONAL PURPOSES ONLY

IF YOU NEED TO USE THIS SEARCH ENGINE, PLEASE IMPLEMENT IT IN A RUBY CLASS AS INDICATED IN THE DOCUMENTATION USING THE APPROPIATE APIs

=end




require File.expand_path(File.dirname(__FILE__) + '/Google_CSE.rb')
require File.expand_path(File.dirname(__FILE__) + '/Google_deferred.rb')

require 'uri'
require 'rexml/document'

class Google_CSE_deferred < Google_CSE
	# Object creation
	#	Parameters
	#		key				API APP key
	#		engine			Custom Search Engine ID to use in requests
	#		user_agent		User agent to use in requests
	#		max_requests	Maximum number of requests to make
	#		proxy			Proxy name or address. Use nil for no proxy.
	#						By default (:ENV), Ruby 2.1 uses HTTP_PROXY environment variable to set the proxy
	#		proxy_port		Proxy port
	#		proxy_user		Proxy username, if required
	#		proxy_password	Proxy password, if required.
	def initialize(key, engine, user_agent="G-API-RubyProg", max_requests=3, proxy=:ENV, proxy_port=nil, proxy_user=nil, proxy_password=nil)	
		super(key, engine, user_agent, max_requests, proxy, proxy_port, proxy_user, proxy_password)

		# Object to use to get deferred info
		set_deferred(Google_deferred.new(user_agent, proxy, proxy_port, proxy_user, proxy_password))				
	end
end
